package com.jia.lidao.ui.message;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;

import com.jia.lidao.R;
import com.jia.lidao.ui.BaseActivity;


/**
 * Created by 00029935 on 2017/11/17.
 */

public abstract class LoaderContentFragmentActivity extends BaseActivity {
    private Fragment currentFragment;



    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(getLayout());
        init();

    }

    protected int getLayout(){
       return R.layout.activity_viewpage;
    }

    private void init() {
        currentFragment = Fragment.instantiate(this, getContentFragment().getName(), null);
        getSupportFragmentManager().beginTransaction().replace(getContentFragmentID(), currentFragment).commit();
    }

    /**
     * @return Fragment class
     */
    protected abstract Class<? extends Fragment> getContentFragment();

    /**
     * @return fragment content id
     */
    protected  int getContentFragmentID(){
        return R.id.content_fragment;
    }

}
